<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        img{
            width: 500px;
            height: 400px;
        }
    </style>
</head>
<body>
    <button id="del">删除图片</button>
    <button id="rep">替换图片</button>
    <br>
    <img src="img/1.jpeg" alt="">
    <img src="img/2.jpg" alt="">

    <script>
        document.querySelector('#del').addEventListener('click',function(){
            //获取当前页面中所有的img标签
            var imgs = document.querySelectorAll('img');
            document.body.removeChild(imgs[0]);
        });
        document.querySelector('#rep').onclick = function(){
            //获取当前页面中所有的img标签
            var imgs = document.querySelectorAll('img');
            imgs[1].src = 'img/3.jpeg';
        };
    </script>
</body>
</html>